package com.hospital.frontdesk.fronxiang.controller;

import com.github.pagehelper.PageInfo;
import com.hospital.frontdesk.fronxiang.entity.DoctorQueue;
import com.hospital.frontdesk.fronxiang.entity.UserDepartment;
import com.hospital.frontdesk.fronxiang.service.DoctorQueueService;
import com.hospital.frontdesk.fronxiang.service.UserDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @description：
 * @author：xyj
 * @date：2021/9/17 15:14
 * @versions：v1.0
 */
@Service
@RequestMapping("/Doctor")
public class DoctorQueueController {

    @Autowired
    private DoctorQueueService doctorQueueService;
    @Autowired
    private UserDepartmentService userDepartmentService;

    @RequestMapping("/pagequeue")
    public String pagequeue(Model model, @RequestParam(defaultValue = "-1") Integer patientId, @RequestParam(value = "curr", defaultValue = "1") Integer curr, @RequestParam(defaultValue = "5") Integer pageSize) {
        List<UserDepartment> departmentlist = userDepartmentService.Departmentlist();
        model.addAttribute("departmentlist", departmentlist);
        List<DoctorQueue> pagequeue = doctorQueueService.pagequeue(patientId, curr, pageSize);
        PageInfo<DoctorQueue> doctorQueuePageInfo = new PageInfo<>(pagequeue);
        model.addAttribute("doctorQueuePageInfo", doctorQueuePageInfo);
        model.addAttribute("patientId", patientId);
        return "frontdesk/queue";
    }

}
